{# Reusable grid-style template card partial for templates page #}
{# Usage: {% include 'assets/partials/template_card_grid.html' with template=template %} #}
<div class="template-card">
    <div class="template-size-indicator">
        {{ template.get_label_size_display }}
    </div>
    
    <div class="template-preview label-size-{{ template.label_size }}">
        {% if template.preview_image %}
            <img src="{{ template.preview_image.url }}" alt="预览" class="img-fluid preview-image-full" loading="lazy" decoding="async">
        {% else %}
            <div class="text-center text-muted">
                <i class="fas fa-tag fa-3x mb-2 icon-primary"></i>
                <div class="fw-bold">{{ template.label_size }}</div>
                <small>Brother PT-9500PC</small>
            </div>
        {% endif %}
    </div>
    
    <div class="template-stats">
        <span class="template-usage-count">
            <i class="fas fa-chart-line me-1"></i>使用 {{ template.usage_count|default:0 }} 次
        </span>
        <span class="text-muted">
            <i class="fas fa-clock me-1"></i>{{ template.created_at|date:"m-d" }}
        </span>
    </div>
    
    <h6 class="mb-2 fw-bold">{{ template.name }}</h6>
    
    <div class="small text-muted mb-3">
        <div class="d-flex align-items-center mb-1">
            <i class="fas fa-print me-2 text-primary"></i>
            <span>{{ template.get_printer_model_display }}</span>
        </div>
        <div class="d-flex align-items-center mb-1">
            <i class="fas fa-user me-2 text-success"></i>
            <span>{{ template.created_by.username }}</span>
        </div>
        {% if template.description %}
        <div class="d-flex align-items-start">
            <i class="fas fa-info-circle me-2 text-info mt-1"></i>
            <span>{{ template.description|truncatechars:60 }}</span>
        </div>
        {% endif %}
    </div>
    
    {% include 'assets/partials/template_actions_grid.html' with template=template %}
    
    <div class="d-flex justify-content-between align-items-center mt-3">
        <div class="small">
            {% if template.is_public %}
                <span class="badge bg-success"><i class="fas fa-globe me-1"></i>公开</span>
            {% elif template.shared_users.exists %}
                <span class="badge bg-info"><i class="fas fa-share me-1"></i>共享</span>
            {% else %}
                <span class="badge bg-secondary"><i class="fas fa-lock me-1"></i>私有</span>
            {% endif %}
        </div>
        <div class="small text-muted">
            <i class="fas fa-layer-group me-1"></i>{{ template.fields_config|length|default:0 }} 字段
        </div>
    </div>
</div>
